<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-07-12 10:56:47
 * @LastEditors: weiting112 10254483+weiting112@user.noreply.gitee.com
 * @LastEditTime: 2022-09-07 21:57:43
-->
<template>
  <div>
    <!-- 头部 -->
    <Header></Header>

    <!-- 体部 -->
    <div class="content">
      <div class="wrapper">
        <div class="content_main">
          <div class="left">
            <div class="t">
              <p>{{name}}</p>
              <a href="#">当前位置：新闻网首页>{{name}}>正文</a>
            </div>
            <div class="content_title">
              <h1>{{ article.title }}</h1>
              <div class="xq">
                <span>作者：{{author.realname}}</span>
                <span>日期：{{article.publishTime | fmtTime}}</span>
                <span>浏览量：{{article.readTimes}}</span>
              </div>
            </div>
            <div class="share">
              <ul>
                <li>分享：</li>
                <li>
                  <a class="weixin"></a>
                </li>
                <li>
                  <a class="weibo"></a>
                </li>
                <li>
                  <a class="fenxiang"></a>
                </li>
                <li>
                  <a class="kongjian"></a>
                </li>
              </ul>
            </div>
            <div class="main_text" v-html="article.content" >
            </div>
          </div>

          <div class="right">
            <div class="t">
              <p class="txt">今日交大</p>
            </div>
            <div class="right_list">
              <ul>
                <li v-for="item in jinrejiaoda.aritcle" :key="item.id">
                  <a href="" class="r_text">{{ item.title }}</a>
                  <a href="" class="three">
                    <i></i>
                    {{ item.publishTime | fmtDate }}
                  </a>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 体部 -->

    <!-- 底部 -->
    <Footer></Footer>
  </div>
</template>

<script>
import { get } from "@/utils/request";
export default {
  data() {
    return {
      // 今日交大
      jinrejiaoda: [],
      id: "",
      name:"",
      article: {},
      author:{}
    };
  },
  methods: {
    // 查找所有资讯分类
    async FindAllCate() {
      let res = await get("/index/article/findCategoryArticles");
      console.log(res);
      this.categories = res.data;
      this.jinrejiaoda = this.categories[12];
    },
     //根据文章id 获取对应得文章
     async getArticleById() {
      let res = await get("/index/article/findById", { id: this.id });
      console.log(res, "获取响应");
      this.article = res.data;
      this.author=res.data.baseUser;
      // {id,title,content}
    },
  },

  created() {
    // console.log(this.$route.query);
    this.id = this.$route.query.id;
    this.name = this.$route.query.name;
    // console.log(this.id,'iii');
    this.getArticleById();
    // 栏目名称
    this.FindAllCate();
  },
};
</script>

<style lang="scss">
// 背景图片
.bgBackground {
  width: 100%;
  height: 100%;
}

// 体部样式
.content {
  position: relative;
  margin-top: -55px;
  .t {
    padding-top: 24px;
    border-bottom: 1px solid #b3b3b3;
    padding-bottom: 10px;
    height: 28px;
    margin-bottom: 20px;
    p {
      float: left;
      font-weight: normal;
      margin: 0;
      font-size: 20px;
      color: #b12922;
      padding-bottom: 10px;
      border-bottom: 2px solid #b12922;
    }
    span {
      font-size: 18px;
      color: #b22923;
      font-weight: bold;
    }
    a {
      float: right;
      font-size: 14px;
      color: #333333;
      opacity: 0.5;
    }
  }
  .three {
    width: 90px;
    i {
      background: url("../assets/yxtx/date2.png");
      width: 13px;
      height: 13px;
      display: block;
      float: left;
      margin-top: 3px;
      margin-right: 5px;
    }
  }
  .content_main {
    display: flex;
    justify-content: space-evenly;
    .left {
      width: 850px;
      background: #fff;
      padding: 0 30px;
      .content_title {
        h1 {
          font-size: 22px;
          color: #333333;
          font-weight: bold;
          display: block;
          text-align: center;
          margin-top: 30px;
          margin-bottom: 15px;
        }
        .xq {
          height: 39px;
          line-height: 39px;
          border-top: 1px dashed #eaeaea;
          border-bottom: 1px dashed #eaeaea;
          // display: flex;
          padding-left: 300px;
          box-sizing: border-box;
          span {
            // display: inline-block;
            font-size: 13px;
            color: #666666;
            margin-right: 25px;
          }
        }
      }
      .share {
        // height: 200px;
        ul {
          float: left;
          li {
            // height: 42px;
            margin: 10px 30px;
            a {
              width: 42px;
              height: 41px;
              display: block;
            }
            .weixin {
              background: url(../assets/yxtx/share_21.png);
            }
            .weibo {
              background: url(../assets/yxtx/share_23.png);
            }
            .fenxiang {
              background: url(../assets/yxtx/share_24.png);
            }
            .kongjian {
              background: url(../assets/yxtx/share_22.png);
            }
          }
        }
      }
      .main_text {
        padding: 30px 30px;
        box-sizing: border-box;
      }
    }
    .right {
      box-sizing: border-box;
      background: #fff;
      padding: 0 32px;
      height: 600px;
      width: 382px;
      .txt {
        font-size: 20px;
        color: #b12922;
        font-weight: bold;
        padding-bottom: 10px;
        border-bottom: 2px solid #b12922;
      }
      .right_list {
        ul {
          li {
            padding: 17px 0;
            border-bottom: 1px dashed #e5e5e5;
            .r_text {
              display: block;
              font-size: 15px;
              color: #333333;
              line-height: 35px;
              text-overflow: ellipsis; //多余的部分显示省略号
              overflow: hidden; //多余的部分隐藏
              white-space: nowrap; //让文字强制一行显示
            }
          }
        }
      }
    }
  }
}
</style>